PHPX_INCLUDE_DIR = "./PHP-X"
PHP_INCLUDE = `php-config --includes`
PHP_INCLUDE_DIR = `php-config --include-dir`
PHP_EXTENSION_DIR = `php-config --extension-dir`

OS_NAME = $(shell uname)
LC_OS_NAME = $(shell echo $(OS_NAME) | tr '[A-Z]' '[a-z]')
LDFLAG = -fPIC -shared
ifeq ($(LC_OS_NAME), darwin)
LDFLAG = -fPIC -shared -undefined dynamic_lookup
endif

all: mysql_proxy.cpp
	c++ -DHAVE_CONFIG_H -g -O2 -o mysql_proxy.so  -fPIC -shared ${LDFLAG} mysql_proxy.cpp  ${PHP_INCLUDE} -std=c++11 -I${PHPX_INCLUDE_DIR}/include -I${PHP_INCLUDE_DIR}/ext/swoole/include -I${PHP_INCLUDE_DIR}/ext/swoole

install: mysql_proxy.so
	cp mysql_proxy.so ${PHP_EXTENSION_DIR}/
clean: mysql_proxy.so
	rm mysql_proxy.so
